/**
 * 
 */
package earserpdf;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpProcessor;

/**
 * <p>Title:RemoveRedactedContent</p>
 * <p>Description:TODO</p>
 * @author	xiongf
 * @date	2015年12月8日 下午8:02:35
 * @version 1.0
 */
public class RemoveRedactedContent {
	
	 public static final String SRC = "E:/Workspace/ItextPDFDemo/pdffolder/page229_redacted.pdf";
	    public static final String DEST = "E:/Workspace/ItextPDFDemo/pdffolder/page229_apply_redacted.pdf";
	 
	    public static void main(String[] args) throws IOException, DocumentException {
	        File file = new File(DEST);
	        file.getParentFile().mkdirs();
	        new RemoveRedactedContent().manipulatePdf(SRC, DEST);
	    }
	 
	    public void manipulatePdf(String src, String dest) throws IOException, DocumentException {
	        PdfReader reader = new PdfReader(src);
	        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
	        PdfCleanUpProcessor cleaner = new PdfCleanUpProcessor(stamper);
	        cleaner.cleanUp();
	        stamper.close();
	        reader.close();
	    }

}
